package com.cqjtu.drive.controller;

import com.cqjtu.drive.pojo.Reservation;
import com.cqjtu.drive.response.Response;
import com.cqjtu.drive.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author zxl
 * @Date 2024/6/17 17:36
 */

@RestController
public class ReservationController {

    @Autowired
    ReservationService reservationService;

    @PostMapping("/api/reservation/insert")
    public Response<String> insertOne(@RequestBody Reservation reservation) {
        return reservationService.insertReservation(reservation);
    }

    @PostMapping("/api/reservation/delete")
    public Response<String> deleteOne(@RequestParam String rid){
        return reservationService.deleteReservation(rid);
    }

    @PostMapping("/api/reservation/update1")
    public Response<String> updateOne1(@RequestBody Reservation reservation){
        return reservationService.updateReservation1(reservation);
    }

    @PostMapping("/api/reservation/update2")
    public Response<String> updateOne2(@RequestBody Reservation reservation){
        return reservationService.updateReservation2(reservation);
    }
    @PostMapping("/api/reservation/getall")
    public List<Map<String, String>> getall(){
        return reservationService.getAllReservations();
    }

    @PostMapping("/api/reservation/getallWithAccept0")
    public List<Map<String, String>> getAllReservationsWithAccept0(){
        return reservationService.getAllReservationsWithAccept0();
    }

    @PostMapping("/api/reservation/getallWithFinish1")
    public List<Map<String, String>> getallWithFinish1(@RequestParam String coId){
        return reservationService.getAllReservationsWithFinish1(coId);
    }

    @PostMapping("/api/reservation/getBysid")
    public List<Map<String, String>> getBysId(@RequestParam String sId){
        return reservationService.getReservationsByStudentId(sId);
    }
    @PostMapping("/api/reservation/getBycoId")
    public List<Map<String,String>> getBycoId(@RequestParam String coId){
        return reservationService.getBycoId(coId);
    }
}
